package com.duomai.myapplication.frament;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.duomai.myapplication.R;
import com.duomai.myapplication.activity.ComplaintActivity;
import com.duomai.myapplication.activity.CostActivity;
import com.duomai.myapplication.activity.EventsActivity;
import com.duomai.myapplication.activity.ForumActivity;
import com.duomai.myapplication.activity.NoticeActivity;
import com.duomai.myapplication.activity.PersonalActivity;
import com.duomai.myapplication.adapter.UserHomeAdapter;
import com.duomai.myapplication.base.BaseFragMent;

import java.util.ArrayList;
import java.util.List;

public class UserHomeFragment extends BaseFragMent {
    UserHomeAdapter homeAdapter;
    RecyclerView recyclerView;

    @Override
    protected int initlayout() {
        return R.layout.fragment_user_home;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        recyclerView = view.findViewById(R.id.recyclerView);
        homeAdapter = new UserHomeAdapter();
        recyclerView.setAdapter(homeAdapter);
        List<String> list = new ArrayList<>();
        list.add("社区通知");
        list.add("投诉建议");
        list.add("论坛");
        list.add("活动");
        list.add("费用缴纳");
        list.add("个人信息");
        homeAdapter.setNewData(list);
        homeAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                switch (position) {
                    case 0:
                        startActivity(new Intent(getActivity(), NoticeActivity.class));
                        break;
                    case 1:
                        startActivity(new Intent(getActivity(), ComplaintActivity.class));
                        break;
                    case 2:
                        startActivity(new Intent(getActivity(), ForumActivity.class));
                        break;
                    case 3:
                        startActivity(new Intent(getActivity(), EventsActivity.class));
                        break;
                    case 4:
                        startActivity(new Intent(getActivity(), CostActivity.class));
                        break;
                    case 5:
                        startActivity(new Intent(getActivity(), PersonalActivity.class));
                        break;
                }
            }
        });
    }

    @Override
    protected void initview() {
    }

    @Override
    protected void loadData() {

    }
}